package com.excletojson;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
public class EasyExcelListener extends AnalysisEventListener<ExcelEntity> {
    List<ExcelEntity> list = new ArrayList<>();
    Map<String,Long> elementMap = new HashMap<>();
    Map<String,Long> eventNameMap = new HashMap<>();
    @Override
    public void invoke(ExcelEntity excelEntity, AnalysisContext analysisContext) {
        //do some business logic
        log.info("一行一行读取数据，可以设置批次");
        list.add(excelEntity);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        //do some business logic
        log.info("数据读取完毕");
    }

    public List<ExcelEntity> getDatas() {
        return list;
    }
}
